﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BrokerBase.Lib.Person;
using BrokerBase.Lib.Core;

namespace Broker.View.PersonView
{
    /// <summary>
    /// HumanRelationTypeForm.xaml 的交互逻辑
    /// </summary>
    public partial class HumanRelationTypeForm 
    {
        private IHumanRelationType humanRelationType;
        private Action callBack;

        public HumanRelationTypeForm(IHumanRelationType humanRelationType, Action callBack)
        {
            this.humanRelationType = humanRelationType;
            this.callBack = callBack;

            InitializeComponent();
            this.Loaded += new RoutedEventHandler(HumanRelationTypeForm_Loaded);
        }

        void HumanRelationTypeForm_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = humanRelationType;
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                IBaseService<HumanRelationType> service = new BaseService<HumanRelationType>(LibGlobal.HbmSessionFactory.GetCurrentSession());

                service.SaveOrUpdate(humanRelationType as HumanRelationType);

                if (callBack != null)
                {
                    callBack();
                }

                MessageBox.Show("人际关系类型保存成功", "提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }


    }
}
